package com.wxz.sanguo.game.general;

import java.util.ArrayList;
import java.util.List;

import com.wxz.sanguo.game.soldier.SoldierType;

/****
 * 
 * @author wxz
 * 
 */
public class SoldierTypeCommand implements Command {

	private SoldierType soldierType;

	private List<TacticType> tacticList;

	private int currentPosition;

	private TacticType lockTacticType;

	private boolean isLock;

	public SoldierTypeCommand(SoldierType type) {
		this.soldierType = type;
		this.tacticList = new ArrayList<TacticType>();
		this.tacticList.add(TacticType.WAIT);
		this.tacticList.add(TacticType.FORWARD);
		this.tacticList.add(TacticType.BACK);
		this.tacticList.add(TacticType.SURROUND);
	}

	@Override
	public void beforeTactic() {
		if (isLock) {
			return;
		}
		if (currentPosition <= 0) {
			currentPosition = 3;
		} else {
			currentPosition--;
		}

	}

	@Override
	public void nextTactic() {
		if (isLock) {
			return;
		}
		if (currentPosition >= 3) {
			currentPosition = 0;
		} else {
			currentPosition++;
		}

	}

	@Override
	public String getCurrentTacticName() {

		if (isLock) {
			return this.lockTacticType.getName();
		}
		return this.tacticList.get(currentPosition).getName();
	}

	@Override
	public int getCurrentTacticPoint() {
		return 0;
	}

	@Override
	public String getName() {
		return this.soldierType.getName();
	}

	public SoldierType getSoldierType() {
		return soldierType;
	}

	public TacticType getCurrentTacticType() {
		if (isLock) {
			return this.lockTacticType;
		}
		return this.tacticList.get(currentPosition);
	}

	public void setLockTacticType(TacticType lockTacticType) {
		this.lockTacticType = lockTacticType;
	}

	public void lock() {
		this.isLock = true;
	}

	public void unLock() {
		this.isLock = false;
	}

}
